#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#define MAX 1000

void my_scanf(int* n, int len)
{
    for (int i = 0; i < len; i++)
    {
        scanf("%d", n++);
    }
}

int* combine(const int* n1, const int* n2, const int n, const int m)
{
    int i = 0;
    int j = 0;
    int combine[2*MAX];
    int* p = combine;
    for (i = 0; i < n;)
    {
        for (j = 0; j < m;)
        {
            if (n1[i] < n2[j])
            {
                combine[i + j] = n1[i];
                i++;
                if (i == n)
                {
                    break;
                }
            }
            else
            {
                combine[i + j] = n2[j];
                j++;
            }
        }
    }
    if (i + j < n + m)
    {
        for (i; i < n; i++)
        {
            combine[i + j] = n1[i];
        }
        for (j; j < m; j++)
        {
            combine[i + j] = n2[j];
        }
    }
    return p;
}

int main()
{
    int n = 0, m = 0;
    scanf("%d %d", &n, &m);
    int len = n + m;
    int n1[MAX];
    int n2[MAX];
    my_scanf(n1, n);
    my_scanf(n2, m);
    int* p = combine(n1, n2, n, m);
    for (int i = 0; i < n + m; i++)
    {
        printf("%d ", *p++);
    }
    return 0;
}